package com.ys.erp.stage_user_service.controller;

import cn.hutool.core.util.ObjectUtil;
import com.ys.erp.common.enums.EnableEnum;
import com.ys.erp.common.enums.TypeEnum;
import com.ys.erp.common.enums.old.TypeOldEnum;
import com.ys.erp.framework.annotation.CheckEmpLogin;
import com.ys.erp.framework.annotation.ResponseResult;
import com.ys.erp.framework.annotation.StageLoginEmp;
import com.ys.erp.framework.bean.dto.StageEmpDTO;
import com.ys.erp.framework.exception.YsException;
import com.ys.erp.framework.response.AbstractResponseCode;
import com.ys.erp.framework.response.PageDTO;
import com.ys.erp.stage_user_service.bean.condition.UserCatCondition;
import com.ys.erp.stage_user_service.bean.condition.UserCondition;
import com.ys.erp.stage_user_service.bean.vo.UserVO;
import com.ys.erp.stage_user_service.service.UserCatService;
import com.ys.erp.stage_user_service.service.UserService;
import io.swagger.annotations.ApiOperation;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author 南山
 * @date 2025/07/05 14:39
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("/manage/user/cat")
@Tag(name = "用户猫咪相关接口", description = "用户猫咪相关接口")
@ResponseResult
public class UserCatController {

    private final UserCatService userCatService;




    @PostMapping("/addUserCat")
    @ApiOperation(notes = "添加用户猫咪", value = "添加用户猫咪")
    public void addUserCat(@RequestBody @Valid UserCatCondition.AddUserCatCon con,
                           @StageLoginEmp StageEmpDTO empDto) {

  /*      if (con.getContractType() == TypeOldEnum.CAT_CONTRACT_METHOD.getType() && con.getIsPre() == EnableEnum.NO.getEnable() && ObjectUtil.isEmpty(con.getCatPeriod())) {
            throw new YsException(AbstractResponseCode.VALID_ERROR);
        }
        if (con.getContractType() == TypeOldEnum.CAT_CONTRACT_ALL_IN.getType() && ObjectUtil.isEmpty(con.getFullMoney())) {
            throw new YsException(AbstractResponseCode.VALID_ERROR);
        }
        if (con.getIsPre() == EnableEnum.NO.getEnable() && con.getIsSignContract() == EnableEnum.NO.getEnable()) {
            throw new YsException(AbstractResponseCode.VALID_ERROR);
        }
        if (con.getIsPre() == EnableEnum.YES.getEnable() && ObjectUtil.isEmpty(con.getPreReason())) {
            throw new YsException(AbstractResponseCode.VALID_ERROR);
        }
        if (con.getIsPre() == EnableEnum.NO.getEnable() && ObjectUtil.isEmpty(con.getTakeDate())) {
            throw new YsException(AbstractResponseCode.VALID_ERROR);
        }
        if (con.getIsPre() == EnableEnum.NO.getEnable()) {
            con.setPreReason(null);
        }
        userCatService.addUserCat(empDto, con);*/
    }



    @PostMapping("/pageUser")
    @Operation(summary = "分页用户", description = "分页用户")
    @CheckEmpLogin
    public PageDTO<UserVO> pageUser(@RequestBody @Valid UserCatCondition.UserCatContractAddCon con,
                                    @StageLoginEmp StageEmpDTO empDto) {
        return userCatService.addContract(empDto, con);
    }


}
